package day5.client;

import day5.client.handler.ChannelInitHandler;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import java.io.IOException;
import java.net.InetSocketAddress;

public class NettyStartClient {
    public static void main(String[] args) throws InterruptedException, IOException {
        Channel channel = new Bootstrap()
                .group(new NioEventLoopGroup())
                .channel(NioSocketChannel.class)
                .handler(new ChannelInitHandler())
                .connect(new InetSocketAddress("localhost", 8080))
                .sync()
                .channel();
        byte[] b = new byte[]{0x11,0x12,0x13};
        channel.writeAndFlush(Unpooled.copiedBuffer(b));
        System.in.read();
    }
}
